Any XML mod use stand-alone tree mod such as Tree::Simple?

Ron Savage on 2009-03-21T09:27:09

Hi Folks

Seems to me many XML parsers talk about tree structures, but so far I have not been able to find one which uses a stand-alone tree module such as Tree::Simple.

Does anyone know of such a beast?

TIA.


What are your requirements?

grantm on 2009-03-21T18:45:49

It might help to answer your question if we knew what you want to do with the tree.

One of the disadvantages of a complex tree structure is the tedium of navigating it to access the data you want. In the XML world, the XPath query language is great for pulling data out of the DOM tree. So having a parser that uses a generic tree module without XPath support doesn't sound particularly appealing.

The most popular XML module is probably XML::LibXML. Its tree nodes and XPath query engine are implemented in the libxml2 C library. This has a huge performance advantage over modules that implement their tree with Perl data structures since Perl has more overheads.

Re:What are your requirements?

Ron Savage on 2009-03-21T23:18:24

Hi Grant

'tedium of navigating' is your problem :-). I'm quite happy to think in terms of tree traversal.

Also, I have no intention of using XPath for the sorts of things /I/ want to do.

Also, I'm interested in what motivates people to write modules in various ways.

Also, I'm interested in a pure Perl solution.

Also, I'm not worried about the overhead of various mechanisms, but I am interested in the /availability/ of various mechanisms,

Cheers

Tree::Simple::SAX

Stevan on 2009-03-22T19:22:32

I wrote Tree::Simple::SAX a while back but never really went anywhere with it. If nothing more it would be a good starting point.

- Stevan

Re:Tree::Simple::SAX

Ron Savage on 2009-03-23T09:40:49

Hi Stevan

The problem is that your sub characters() assumes it is called only once per set of chars, but as explained in XML::SAX::Intro this is not necessarily true :-(.

Cheers

Re:Tree::Simple::SAX

Stevan on 2009-03-23T15:20:03

Ron,

I suspect that is easy to fix, you are welcome to fork this on github and patch away. In fact if you want I will gladly give you co-maint on CPAN as well.

- Stevan

Re:Tree::Simple::SAX

Ron Savage on 2009-03-23T21:04:07

Hi Stevan

Thanx for the offer, and yes, I'm sure it's be easy to fix. I'll tempted, so I'll think about it...
And I do love SAX-style processing.